package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.AirportServiceItem;
import com.ktgj.service.service.IAirportServiceItemService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 机场服务明细Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/item")
public class AirportServiceItemController extends BaseController
{
    @Autowired
    private IAirportServiceItemService airportServiceItemService;

    /**
     * 查询机场服务明细列表
     */
    @PreAuthorize(hasPermi = "service:item:list")
    @GetMapping("/list")
    public TableDataInfo list(AirportServiceItem airportServiceItem)
    {
        startPage();
        List<AirportServiceItem> list = airportServiceItemService.selectAirportServiceItemList(airportServiceItem);
        return getDataTable(list);
    }

    /**
     * 导出机场服务明细列表
     */
    @PreAuthorize(hasPermi = "service:item:export")
    @Log(title = "机场服务明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AirportServiceItem airportServiceItem) throws IOException
    {
        List<AirportServiceItem> list = airportServiceItemService.selectAirportServiceItemList(airportServiceItem);
        ExcelUtil<AirportServiceItem> util = new ExcelUtil<AirportServiceItem>(AirportServiceItem.class);
        util.exportExcel(response, list, "机场服务明细数据");
    }

    /**
     * 获取机场服务明细详细信息
     */
    @PreAuthorize(hasPermi = "service:item:query")
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") Long itemId)
    {
        return AjaxResult.success(airportServiceItemService.selectAirportServiceItemById(itemId));
    }

    /**
     * 新增机场服务明细*/
    @PreAuthorize(hasPermi = "service:item:add")
    @Log(title = "机场服务明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AirportServiceItem airportServiceItem)
    {
        return toAjax(airportServiceItemService.insertAirportServiceItem(airportServiceItem));
    }

    /**
     * 修改机场服务明细*/
    @PreAuthorize(hasPermi = "service:item:edit")
    @Log(title = "机场服务明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AirportServiceItem airportServiceItem)
    {
        return toAjax(airportServiceItemService.updateAirportServiceItem(airportServiceItem));
    }

    /**
     * 删除机场服务明细*/
    @PreAuthorize(hasPermi = "service:item:remove")
    @Log(title = "机场服务明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable Long[] itemIds)
    {
        return toAjax(airportServiceItemService.deleteAirportServiceItemByIds(itemIds));
    }
}
